package com.gocoolmall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.gocoolmall.common.valid.AddGroup;
import com.gocoolmall.common.valid.ListValue;
import com.gocoolmall.common.valid.UpdateGroup;
import com.gocoolmall.common.valid.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 商品品牌表
 * @author zhangxiaobo
 * @email 1926992064@qq.com
 * @date 2020-12-09 16:35:22
 */
@Data
@TableName("pms_brand")

public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	/**
	 * 品牌id
	 */
	@NotNull(message = "修改必须指定品牌id",groups = {UpdateGroup.class})
	@Null(message = "新增不能指定id",groups = {AddGroup.class})
	@TableId
	private Long brandId;
//	品牌名
	//jsr303校验规则包：Maven:javax.validation:validation-api:2.0.1.Final >>\javax\validation\constraints
//	https://blog.csdn.net/weixin_44440642/article/details/106335653
	//@NotNull @NotBlank   @NotEmpty
	//1、在用的实体类的地方 开启校验注解 @Valid
	//2、添加校验注解和提示信息  @NotBlank(message="品牌名必须提交")
	//3、实体类的bean 返回校验结果 BindingResult
	//4、分组校验(完成多场景的复杂校验)，
	// 				groups = {AddGroup.class,UpdateGroup.class}，
	// 			   @Validated({AddGroup.class})
	//             默认没有指定分组的校验注解@NotBlank，在分组情况下不生效，只会在没有分组的情况下才会生效
	//5.自定义校验
	//1）自己编写一个自定义的校验注解
	//2）编写一个自定义的校验器
	//3）关联自定义的校验器和自定义的校验注解
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名必须提交",groups = {AddGroup.class,UpdateGroup.class})
	private String name;

	/**
	 * 品牌logo地址
	 */
	@NotEmpty(groups = {AddGroup.class})
	@URL(message = "logo必须是个合法的url地址",groups = {AddGroup.class,UpdateGroup.class})
	private String logo;

	/**
	 * 介绍
	 */
	private String descript;

	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(groups = {AddGroup.class,UpdateStatusGroup.class})
	@ListValue(value = {0,1},groups = {AddGroup.class,UpdateStatusGroup.class})
	private Integer showStatus;

	/**
	 * 检索首字母
	 */
	@NotEmpty(groups = {AddGroup.class})
	@Pattern(regexp ="^[a-zA-Z]$",message = "检索的首字母必须是一个字母",groups = {AddGroup.class,UpdateGroup.class})
	private String firstLetter;

	/**
	 * 排序
	 */
	@NotNull(groups = {AddGroup.class})
	@Min(value = 0,message = "排序必须大于等于0",groups = {AddGroup.class,UpdateGroup.class})
	private Integer sort;

}
